package com.hsbc.dev.teamo4.sms.sm.service.impl;

import com.hsbc.dev.teamo4.sms.sm.dao.IDictionaryDao;
import com.hsbc.dev.teamo4.sms.sm.dao.impl.DictionaryDaoImpl;
import com.hsbc.dev.teamo4.sms.sm.po.Dictionary;
import com.hsbc.dev.teamo4.sms.sm.service.IDictionaryService;

import java.util.List;

/**
 * @Description: service接口实现
 * @author:Young
 * @version:
 * @Project: permission_manage
 * @Package: com.hsbc.dev.teamo4.sms.sm.service.impl
 * @Date date: 2018/7/28
 */
public class DictionaryServiceImpl implements IDictionaryService {

    private IDictionaryDao dictionaryDao = new DictionaryDaoImpl();//调用dao接口

    /**
     * @Description: 添加字典记录。
     * @Param: [dictionary]
     * @return: com.hsbc.dev.teamo4.sms.sm.po.Dictionary
     * @Author: Young
     * @Date: 2018/7/28
     */
    @Override
    public Dictionary save(Dictionary dictionary) {
        if (dictionary!=null){
            return dictionaryDao.saveEntity(dictionary);
        }
        return null;
    }

    /**
     * @Description: 更新字典记录。
     * @Param: [dictionary]
     * @return: com.hsbc.dev.teamo4.sms.sm.po.Dictionary
     * @Author: Young
     * @Date: 2018/7/28
     */
    @Override
    public Dictionary update(Dictionary dictionary) {
        if (dictionary!=null){
            return dictionaryDao.updateEntity(dictionary);
        }
        return null;
    }

    /**
     * @Description: 根据id查询字典记录。
     * @Param: [id]
     * @return: com.hsbc.dev.teamo4.sms.sm.po.Dictionary
     * @Author: Young
     * @Date: 2018/7/28 
     */
    @Override
    public Dictionary queryById(String id) {
       if (id==null||"".equals(id)){
            return null;
       }
       return dictionaryDao.queryById(id);
    }

    /**
     * @Description: 查看所有的字典记录。
     * @Param: []
     * @return: java.util.List<com.hsbc.dev.teamo4.sms.sm.po.Dictionary>
     * @Author: Young
     * @Date: 2018/7/28
     */
    @Override
    public List<Dictionary> queryEntityList() {
        return dictionaryDao.queryAllEntity();
    }

    @Override
    public int updateByIsEnable(String id, Boolean bool) {
        return dictionaryDao.updateByIsEnable(id,bool);
    }

    /**
     * @Description: 根据字典名称查询出所有匹配的记录。
     * @Param: [dictionaryName]
     * @return: java.util.List<com.hsbc.dev.teamo4.sms.sm.po.Dictionary>
     * @Author: Young
     * @Date: 2018/7/28
     */
    @Override
    public List<Dictionary> findAllDictionaryByName(String dictionaryName) {
        if (dictionaryName==null||"".equals(dictionaryName)){
            return null;
        }
        return dictionaryDao.queryListByName(dictionaryName);
    }

    /**
     * @Description: 删除字典记录。
     * @Param: [id]
     * @return: boolean
     * @Author: Young
     * @Date: 2018/7/28
     */
    @Override
    public boolean deleteDictionary(String id) {
        if (id==null||"".equals(id)){
            return false;
        }
        return dictionaryDao.deleteById(id);
    }
}
